<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<html>
<head>
<Style>
li.w-1of1{overflow:hidden}
</style>
<script language="javascript">
$().ready(function(){
	<c:choose>
	<c:when test="${empty member.email}">
		$("#current_location").html('&nbsp;&gt;&nbsp;<a href="${frontContextPath}/member/modifydata.do">个人信息管理&nbsp;-&nbsp;修改个人信息</a>&nbsp;&gt;&nbsp;维护登录邮箱');
		$("#title_txt").text('维护登录邮箱');
	</c:when>
	<c:otherwise>
		$("#current_location").html('&nbsp;&gt;&nbsp;<a href="${frontContextPath}/member/modifydata.do">个人信息管理&nbsp;-&nbsp;修改个人信息</a>&nbsp;&gt;&nbsp;修改登录邮箱');
	</c:otherwise>
	</c:choose>
	
	$("#m_modifyData").css("font-weight","bold");

	$("span:[id*=Tip]").hide();

	$("#resend_dialog").dialog({
		autoOpen: false,
		bgiframe: true,
		height: 340,
		width:680,
		modal: true
	});

	$("#resend_result1").dialog({
		autoOpen: false,
		bgiframe: true,
		height: 150,
		width:355,
		modal: true
	});

	$("#resend_result2").dialog({
		autoOpen: false,
		bgiframe: true,
		height: 150,
		width:355,
		modal: true
	});
	
	if("${actionResult}" == "m_mail_exist"){
		$("#mailTip").text("该邮箱已被使用");
		$("#mailTip").show();
		$("#resend_dialog").dialog('open');
		$("#modify_send").attr('checked',true);
	}else if("${actionResult}" == "m_pwd_error"){
		$("#pwdTip").text('密码错误');
		$("#pwdTip").show();
		$("#resend_dialog").dialog('open');
		$("#modify_send").attr('checked',true);
	}else if("${actionResult}" == "m_resend_success"){
		$("#resend_result1").dialog('open');
	}else if("${actionResult}" == "m_modify_send_success"){
		$("#resend_result2").dialog('open');
	}
	
	$("#resend_dialog_commit").click(function(){
		var isCorrect = true;

		//clear tips
		$("span:[id*=Tip]").hide();

		if($("#modify_send").attr('checked')){
			$("#mail").val(jQuery.trim($("#mail").val()));	
			if($("#mail").attr('value') == ""){
				$("#mailTip").text("请输入邮箱");
				$("#mailTip").show();
				isCorrect = false;
			}else if($("#mail").attr('value') == "${mail}"){
				$("#mailTip").text("与目前等待确认的邮箱相同");
				$("#mailTip").show();
				isCorrect = false;
			}else if($("#mail").val().match(/.+@.+\..+/)==null || $("#mail").val().indexOf(' ')>=0){
				$("#mailTip").text("邮箱格式错误");
				$("#mailTip").show();
				isCorrect = false;
			}
			
			$("#rcmail").val(jQuery.trim($("#rcmail").val()));
			if($("#rcmail").attr('value') == ""){
				$("#rcmailTip").text("请再次输入您的邮箱地址");
				$("#rcmailTip").show();
				isCorrect = false;
			}else if($("#mail").val() != $("#rcmail").val()){
				$("#rcmailTip").text("两次输入的邮箱地址不一致");
				$("#rcmailTip").show();
				isCorrect = false;
			}
			if($("#pwd").attr('value') == ""){
				$("#pwdTip").text("请输入密码");
				$("#pwdTip").show();
				isCorrect = false;
			}
		}
			
		if(isCorrect){
			//resend
			$("#resendForm").submit();
			return false;
		}
	});

	$("#resend_1").click(function(){
		$("#modify_send").attr('checked',false);
		$("#resend").attr('checked',true);
		$("span:[id*=Tip]").hide();
		$("#resend_dialog").dialog('open');
	});

	$("#resend_2").click(function(){
		$("#resend").attr('checked',false);
		$("#modify_send").attr('checked',true);
		$("span:[id*=Tip]").hide();
		$("#resend_dialog").dialog('open');
	});

	$("#resend_result_close1").click(function(){
		$("#resend_result1").dialog('close');
	});

	$("#resend_result_close2").click(function(){
		$("#resend_result2").dialog('close');
	});
});
</script>
</head>
<h2 id="title_txt">修改登录邮箱</h2>
      <div class="change-email">
          <div class="ok-img"><p class="txt-m"><strong>验证邮件已发出！</strong></p>
            <p>已成功向 <span class="txt-rd">${mail} </span>发送验证邮件。</p>
          </div>
          <div class="txt-note">
            <strong>提示：</strong>
            <ul>
              <li>．若您长时间未收到验证邮件，可能是验证邮件被您的邮箱提供商认定为广告或垃圾邮件，或是您提交了错误的邮箱地址，如还是找不到该邮件，可点<a href="javascript:;" id="resend_1">重新发送验证邮件</a>。</li>
              <li>．您也可再次<a href="javascript:;" id="resend_2">更改邮箱地址</a>，用其他的郵箱再收一封新的验证邮件。 </li>
              <li>．如果您多次修改邮箱地址，那么只有最后的一封确认信是有效的。</li>
            </ul>
        </div>
      </div>
      
<div id="resend_dialog" title="重新发送验证邮件" class="m-regform" style="display:none;">
<s:form action="resendModifyEmail.do" method="post" id="resendForm">
<input type="hidden" name="loginID" value="${loginID}">
<ul>
<li class="w-1of1"><div class="w-head">等待确认的邮箱地址：</div><div>${mail}</div></li>
<li class="w-1of1"><div class="w-check"><input type="radio" name="choice" id="resend" checked="checked" /> 重新发送验证邮件到上面邮箱地址：请直接点选下方的确认按钮，即可完成申请。</div></li>
<li class="w-1of1"><div class="w-check"><input type="radio" name="choice" id="modify_send" /> 更改上面的邮箱地址，并申请验证邮件：请完整填写以下信息后，再按确认按钮即可。</div></li>
<li class="w-1of1"><div class="w-head">请输入新邮箱地址：</div><div><input type="text" name="mail" id="mail" maxlength="100"/><span style="display:block;"><span id="mailTip" class="msg rn">邮箱格式错误</span></span></div><div class="w-note">请使用您常用邮箱，方便日后重要信息通知。</div></li>
<li class="w-1of1"><div class="w-head">请再次输入新邮箱地址：</div><div><input type="text" id="rcmail" maxlength="100"/><span style="display:block;"><span id="rcmailTip" class="msg rn"></span></span></div></li>
<li class="w-1of1"><div class="w-head">请输入登录密码：</div><div><input type="password" name="pwd" id="pwd" maxlength="16"/><span style="display:block;"><span id="pwdTip" class="msg rn">请输入密码</span></span></div></li>
</ul>
<div align="center">
<span style="text-align:center;"><a href="javascript:;" class="btn-mid" id="resend_dialog_commit">确认</a></span>
</div>
</s:form>
</div>

<div id="resend_result1" title="成功发送验证邮件" class="member-reg-alert-ok" style="display:none;"> 
	<p>已成功向 <span class="txt-rd">${mail}</span> <br />发送验证邮件。</p>
	<div align="center">
	<span style="text-align:center;"><a href="javascript:;" class="btn-mid" id="resend_result_close1">关闭</a></span>
	</div>
</div>

<div id="resend_result2" title="已更新邮箱地址，并重新发送验证邮件" class="member-reg-alert-ok" style="display:none;"> 
	<p>已成功向 <span class="txt-rd">${mail}</span> <br />发送验证邮件。</p>
	<div align="center">
	<span style="text-align:center;"><a href="javascript:;" class="btn-mid" id="resend_result_close2">关闭</a></span>
	</div>
</div>
</html>